package contract

import (
	"context"
	"k9-panel/app/model"
	"k9-panel/app/service/dto"
)

type IProject interface {
	Create(project *model.Project) (id uint, err error)
	Update(project *model.Project) (id uint, err error)
	Delete(project *model.Project) (id uint, err error)
	Get(project *model.Project) (p *model.Project, err error)
	QueryList(param *dto.ProjectListParam) ([]*model.Project, error)
	List() ([]*model.Project, error)
}

type IEnvironment interface {
	Create(project *model.Environment) (id uint, err error)
	Delete(project *model.Environment) (id uint, err error)
	Update(project *model.Environment) (id uint, err error)
	List() ([]*model.Environment, error)
	Get(id uint) (*model.Environment, error)
	GetByModel(model *model.Environment) (*model.Environment, error)
	QueryByNames(names []string) ([]*model.Environment, error)
}
type IBaseConfig interface {
	Update(projectId uint, content string) (uint, error)
	Delete(model *model.BaseConfig) (uint, error)
	DeleteByProject(id int) (int64, error)
	GetByProject(id uint) (*dto.ProjectBaseConfigInfo, error)
	GetListByProject(id uint) ([]*model.BaseConfig, error)
	Convert2ConfigEnv(name string, items []*model.BaseConfig) (*dto.ConfigEnv, error)
}

type IDerivedConfig interface {
	Create(projectId uint, envId uint, content string) (uint, error)
	UpdateByParam(param *dto.DerivedAddParam) (uint, error)
	Update(projectId uint, envId uint, content string) (uint, error)
	DeleteByProject(id int) (int64, error)
	GetByProject(id uint, envId uint) (*dto.ProjectBaseConfigInfo, error)
	ViewProject(id uint, envId uint) (*dto.ProjectBaseConfigInfo, error)
}

type IHistoryConfig interface {
	Create(projectId uint, envId uint, content string, memo string) (uint, error)
	Publish(param *dto.HistoryConfigPublishParam) (uint, error)
	UnPublish(projectId uint, envId uint) (uint, error)
	Delete(id uint) (int64, error)
	Get(id uint) (*model.HistoryConfig, error)
	List(history *dto.QueryListHistory) (*dto.RspListHistory, error)
	View(envName string, projectName string) (*model.HistoryConfig, error)
}

type IUserToken interface {
	Query(ctx context.Context, token string) (*model.UserToken, error)
	List() ([]*model.UserToken, error)
	Delete(model *model.UserToken) (uint, error)
	Update(model *model.UserToken) (uint, error)
}

type IAccount interface {
	List() ([]*model.Account, error)

	Create(ctx context.Context, param *model.Account) (uint, error)
	Update(ctx context.Context, param *dto.AccountCreateParam) (uint, error)
	UpdateOtherPassword(ctx context.Context, param *dto.AccountCreateParam) (uint, error)
	Delete(ctx context.Context, param *dto.AccountDeleteParam) (uint, error)
	Query(ctx context.Context, param *dto.AccountQueryParam) (*model.Account, error)
	Get(ctx context.Context, id uint) (*model.Account, error)
}
